package com.tedu.controller;

import com.tedu.pojo.Item;
import com.tedu.pojo.Order;
import com.tedu.pojo.OrderItem;
import com.tedu.pojo.User;
import com.tedu.servies.OrderServies;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;


@Controller
public class OrderController {


    @Autowired
    OrderServies orderServies;


    @RequestMapping("/user/myOrder")
    public String getmyOrder(Model model, HttpSession session) {
        User u = (User) session.getAttribute("user");
        List<Order> allorder = orderServies.getListByUserId(90);
        System.out.println(allorder);
        model.addAttribute("orderVOO",allorder);

        List<String> orderList = new ArrayList<String>();
        for (int i = 0; i < allorder.size(); i++) {
            orderList.add(allorder.get(i).getOrderId());
        }

        System.out.println("libiao");
        System.out.println(orderList);
        List<OrderItem> orderItem = orderServies.getOrderItem(orderList);
        model.addAttribute("orderVOs",orderItem);
        System.out.println("dingdan");
        System.out.println(orderItem);

        return "myOrder";
    }
}
